package com.zby.big_event_zby.learnTest;

/**
 * @version 1.0
 * @auther ZBY
 */
public class Thread01 {
    public static void main(String[] args) {
    new cat().start();//启动线程
        new Dog().start();
        System.out.println("主线程");
        for (int i = 0; i < 100; i++){
            try {
                Thread.sleep(1000);//休眠一秒
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("主线程"+i+"线程名："+Thread.currentThread().getName());
        }
    }
}
class cat extends Thread {
    @Override
    public void run() {

        try {

            for (int i = 0; i < 100; i++) {
                Thread.sleep(1000);//休眠一秒
                System.out.println("喵喵喵"+"线程名："+Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}

class Dog extends Thread {
    @Override
    public void run() {

        try {

            for (int i = 0; i < 100; i++) {
                Thread.sleep(1000);//休眠一秒
                System.out.println("汪汪哇"+"线程名："+Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}